<?php


?>
<div style="width: 500px;margin: 0 auto; background: #eee;padding: 50px">
    <div style="width: 100%">
        <table style="width:100%;" class="_form">
                    <tr>
                        <td style="">
                            <div class="_input-label">
                                <div class="input">
                                    <input type="text" id="txtname" placeholder="" value="admin"/>
                                    <div class="label"><label>User Name</label></div>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="_input-label">
                                <div class="input">
                                    <input type="text" id="txtpass" placeholder="" value="abc123~!@"/>
                                    <div class="label"><label>Password</label></div>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div>
                               
                                <div class="mybutton icon tooltip" style="margin-left: 150px"
                                title="Back" 
                                onclick="login();">
                                <div>
                                    <img src="./images/icon/16/login.png"/><span>Login</span>
                                </div>
                            </div>
                            </div>
                        </td>
                    </tr>
                </table>


        <span id="warningmsg"></span>
    </div>
</div>

    
    
    <script>
        $(document).ready(function(){
            $(".tooltip").tipTip({defaultPosition:"top", edgeOffset: 10});
            tinyMCE.init({
                    mode : "textareas",
                    theme : "advanced",
                    content_css : "/Coffee/css/style.css",
                    editor_selector : "mceEditor",
                    editor_deselector : "mceNoEditor",
                    theme_advanced_resizing : true,
                    theme_advanced_resize_horizontal : false
            });
            $("#txtname").focus();
        });
        
        
        function login(){
            
            if(!_FcheckFilled($("#txtname").val())){$("#txtname").focus();return;}
            if(!_FcheckFilled($("#txtpass").val())){$("#txtpass").focus();return;}
            var surl="./Controller/";
            
            var sdata={
                    "controller":"SystemController",
                    "action":"login",
                    "name":$("#txtname").val(),
                    "pass":$("#txtpass").val()
                    
            };
            jQuery.ajax({
                    type:"POST", 
                    data:sdata, 
                    dataType:"text", 
                    url:surl, 
                    success: function (data){
                        if(data=="true"){
                            $("#warningmsg").html("Sucessful. Reload page in 3 second.");
                            $("#warningmsg").show();
                            setTimeout(function() {
                                location.reload();
                            },3000);
                            showmsg("Sucessful.",2000);
                        }else{
                            showerrorbox(null,data);
                            $("#warningmsg").html(data);
                            $("#warningmsg").show();
                        }

                    },
                    error: function (xhr, ajaxOptions, thrownError){
                            $("#warningmsg").html("<b>Status</b>:"+xhr.status+"<br/><b>ThrownError</b>:"+thrownError);
                            $("#warningmsg").show();
                    }
            });

        }
    </script>
